//
//  FBNetworkTool.h
//  Fireball
//
//  Created by 俞渊华 on 2017/12/2.
//  Copyright © 2017年 俞渊华. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "XMNetworkManager.h"
#import "XMHttpResponseModel.h"


/** 请求成功的Block */
typedef void(^DBHttpRequestSuccess)(XMHttpResponseModel * responseModel);
/** 缓存的Block */
typedef void(^DBHttpRequestCache)(XMHttpResponseModel * responseModel);

@interface FBNetworkTool : NSObject


/**
 *  POST请求,无缓存
 *
 *  @param URL        请求地址
 *  @param parameters 请求参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 *
 *  @return 返回的对象可取消请求,调用cancel方法
 */
+ (__kindof NSURLSessionTask *)get:(NSString *)URL
                        parameters:(id)parameters
                           showHUD:(BOOL)showHUD
                           success:(DBHttpRequestSuccess)success
                           failure:(XMHttpRequestFailed)failure;

+ (__kindof NSURLSessionTask *)get:(NSString *)URL
                        parameters:(id)parameters
                           showHUD:(BOOL)showHUD
                     responseCache:(DBHttpRequestCache)cache
                           success:(DBHttpRequestSuccess)success
                           failure:(XMHttpRequestFailed)failure;



/**
 *  POST请求,无缓存
 *
 *  @param URL        请求地址
 *  @param parameters 请求参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 *
 *  @return 返回的对象可取消请求,调用cancel方法
 */
+ (__kindof NSURLSessionTask *)post:(NSString *)URL
                         parameters:(id)parameters
                            showHUD:(BOOL)showHUD
                            success:(DBHttpRequestSuccess)success
                            failure:(XMHttpRequestFailed)failure;


+ (__kindof NSURLSessionTask *)post:(NSString *)URL
                         parameters:(id)parameters
                            showHUD:(BOOL)showHUD
                      responseCache:(DBHttpRequestCache)cache
                            success:(DBHttpRequestSuccess)success
                            failure:(XMHttpRequestFailed)failure;

@end
